package com.espirit.smc.server;

import java.nio.file.Path;
import java.util.LinkedHashSet;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

import com.espirit.smc.ServerMangerProperties;

public class ServerProperties extends ServerMangerProperties {

	private String watchPaths;
	
	private Set<Path> paths;

	public Set<Path> getWatchPaths() {
		if (this.paths == null && StringUtils.isNotBlank(getRoot())&& StringUtils.isNotBlank(watchPaths)) {
			this.paths = new LinkedHashSet<Path>();
			String[] ps = watchPaths.split(";");
			for (String p : ps) {
				if (p.startsWith(getRoot())) {
					this.paths.add(fs.getPath(p));
				}else{
					Path fullPath = fs.getPath(getRoot(), p);
					this.paths.add(fullPath);
				}
			}
		}
		return paths;
	}

	public void setWatchPaths(String watchPaths) {
		this.watchPaths = watchPaths;
	}
	
}
